﻿using System;
using System.ComponentModel;

namespace MyTinnyApi.model
{
	public class Config: INotifyPropertyChanged
    {
		private string _openedRequests;
		public string OpenedRequests
		{
			get
			{
				return _openedRequests;
			}
			set
			{
				_openedRequests = value;
				OnPropertyChanged(nameof(OpenedRequests));
			}
		}

		public List<int> OpenedRequestIds
		{
			get
			{
				if (string.IsNullOrWhiteSpace(_openedRequests))
				{
					return new List<int> { };
				}
				else
				{
					return _openedRequests.Split(",").Select(idStr => int.Parse(idStr.Trim())).ToList();
				}
			}
		}

		private int? _activedRequest;
		public int? ActivedRequest
		{
			get
			{
				return _activedRequest;
			}
			set
			{
				_activedRequest = value;
				OnPropertyChanged(nameof(ActivedRequest));
			}
		}

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

